package jp.dodododo.dao.object;

import java.util.Map;

import jp.dodododo.dao.annotation.Internal;
import jp.dodododo.dao.util.CacheUtil;

@Internal
public class ObjectDescFactory {

	private static Map<Class<?>, ObjectDesc> objectDescCache = CacheUtil.cacheMap();

	public static ObjectDesc getObjectDesc(Object o) {
		return getObjectDesc(o, true);
	}

	public static ObjectDesc getObjectDesc(Object o, boolean isIgnoreCase) {
		return getObjectDesc(o.getClass(), isIgnoreCase);
	}

	public static ObjectDesc getObjectDesc(Class<?> clazz) {
		return getObjectDesc(clazz, true);
	}

	public static ObjectDesc getObjectDesc(Class<?> clazz, boolean isIgnoreCase) {
		ObjectDesc objectDesc = objectDescCache.get(clazz);
		if (objectDesc == null) {
			objectDesc = new ObjectDesc(clazz, isIgnoreCase);
			objectDescCache.put(clazz, objectDesc);
		}
		return objectDesc;
	}

}
